package com.zero.rocketmq.controller;


import com.zero.rocketmq.producer.SpringProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/MQTest")
public class RocketmqController {

    @Autowired
    private SpringProducer producer;

    public String topic = "TopicTest";


   @RequestMapping(value = "/sendMessage",method = RequestMethod.GET)
    public void sendMessage(String message){
        producer.sendMessage(topic,message);
    }

    @RequestMapping(value = "/sendMessageInTransaction",method = RequestMethod.GET)
    public void sendMessageInTransaction(String message){

       try {
           producer.sendMessageInTransaction(topic,message);
       }catch (Exception e){
           e.printStackTrace();
       }

    }
}
